const jwt = require("jsonwebtoken");//令牌库
const User = require("../database/models/user")
async function parseToken(req, res, next) {
    try {
        const token = jwt.verify(req.body.token, "hds")
        const data = await User.findAll({
            where: {
                id: token.id,
                account: token.account,
            }
        })
        if (!data[0]) return res.status(404).send({
            Informationerror: "该账号不存在！"
        });
        req.token = token;
        return next();
    } catch (error) {
        return res.status(401).send("用户令牌不正确！！！")
    }
}
module.exports = parseToken;